﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineProjectCommand.Commands;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineProjectCommand.CommandHandlers
{
    public class UpdateExamineProjectCommandHandler : IRequestHandler<UpdateExamineProjectCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineProject> _examineprojectRepository;
        public UpdateExamineProjectCommandHandler(IBaseRepository<ExamineProject> examineprojectRepository)
        {
            _examineprojectRepository = examineprojectRepository;
        }
        public Task<APIRequst<int>> Handle(UpdateExamineProjectCommand request, CancellationToken cancellationToken)
        {
            ExamineProject project = new ExamineProject();
            project.ProjectStandard = request.ProjectStandard;
            project.ExamineProjectName = request.ExamineProjectName;
            project.ExamineId = request.ExamineId;
            project.ProjectMethod = request.ProjectMethod;
            project.ProjectStandard = request.ProjectStandard;
            project.Unit = request.Unit;
            project.UpperLimit = request.UpperLimit;
            project.LowerLimit = request.LowerLimit;
            project.ProjectRemark = request.ProjectRemark;
            project.UpdateName = request.UpdateName;
            project.UpdateTime = request.UpdateTime;

            _examineprojectRepository.Update(project);
            return Task.FromResult(new APIRequst<int>
            {
                Code=RequstCode.成功,
                Msg=RequstCode.成功.ToString()
            });
        }
    }
}
